<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link href="{{static_url('css/style.css')}}" rel=stylesheet>
	<!-- 	<link href="css/fangke.css" rel=stylesheet>  -->
	<link rel='stylesheet' href="{{static_url('css/fangke.css')}}" >
	<script type="text/javascript" src="{{static_url('js/jquery-1.7.2.min.js')}}"></script>
	<script type="text/javascript" src="{{static_url('js/picmain.js')}}"></script>
	 	<link href="{{static_url('layui/css/layui.css')}}" rel=stylesheet>
	<script type="text/javascript" src="{{static_url('layui/layui.js')}}"></script>
<style type="text/css">
	


</style>
</head>
<body class="vbody">
		<div class="header">
			<div class="main"> 
			  <a href="" class="logo"><img src="{{static_url('image/logo.jpg')}}" width="446" height="48"/></a>
			<div class="tel">
			 <div class="telnum">联系我们：<span>888-888-88888</span></div>
			 <div class="telphone"><img src="{{static_url('image/telphone.jpg')}}" width="57" height="57" /></div>
			</div>
		  </div>
		</div>
	<div class="cbanner"><img src="{{static_url('image/banner1.jpg')}}" width="100%" height="351" /></div>
<div class="menu">
	  <ul>
		   <li><a href="/index">首页</a></li>
  <!--     <li><a href="">关于我们</a></li> -->
      <!-- <li><a href="/third_rent">第三方租房</a></li> -->
      <li><a href="/rent">寻找房源</a></li>
      <li><a href="/release">发布房源</a></li>
      <li><a href="/advice">投诉建议</a></li>
      <li><a href="/user">个人中心</a></li>
	</ul>
</div>
<!--图片下边  -->
<!-- <div class="fyRight">
  <div class="title">
     <span class="fl">发布</span>
  </div>
</div>
 -->
<div id="formDetail" class="main out">
	    <p class="title">
	        <h1>填写房源基本信息，<span class="baletu-red"></span>工作人员会尽快审核</h1>
	    </p>
	    </br />
	    <div class="form-wrapper form-basic">
	        <div class="form-content">
	            <div>
	                <div class="input-title1">姓名</div>
	                <input type="text" name="user_name" readonly placeholder="请输入房东姓名" id="landlord_name" value="{{userManage['user_name']}}">
					<input type="hidden" name="user_id" value="{{userManage['user_id']}}">
					<p class="tips"></p>
	            </div>
	            <div>
	                <div class="input-title1">电话</div>
	                <input type="phone" name="lan_mobile" readonly value="{{userManage['user_phone']}}">
	                <p class="tips"></p>
	            </div>
				<div>
	                <div class="input-title1">邮箱</div>
	                <input type="email" name="email" readonly value="{{userManage['user_email']}}">
	                <p class="tips"></p>
	            </div>
				<div>
	                <div class="input-title1">醒目标题</div>
	                <input type="text" name="renting_title" placeholder="">
	                <p class="tips"></p>
	            </div>
	           
				<div>
	                <div class="input-title1">城市</div>
	                <input type="text" name="city" placeholder="" value="北京" readonly>
	                <p class="tips"></p>
	            </div>
	            <div>
	                <div class="input-title1">区</div>
	                <select name="region" class="region">
	                	<option value="朝阳"> 朝阳</option>
	                	<option value="西城"> 西城</option>
	                	<option value="东城"> 东城</option>
	                	<option value="丰台"> 丰台</option>
	                	<option value="石景山"> 石景山</option>
	                	<option value="海淀"> 海淀</option>
	                	<option value="门头沟"> 门头沟</option>

	                	<option value="通州"> 通州</option>
	                	<option value="昌平"> 昌平</option>
	                	<option value="顺义"> 顺义</option>
	                	<option value="大兴"> 大兴</option>
	                	<option value="怀柔"> 怀柔</option>
	                	<option value="平谷"> 平谷</option>
	                	<option value="密云"> 密云</option>
	                	<option value="延庆"> 延庆</option>
	              </select>
	                <p class="tips"></p>
	            </div>
	            <div id="door-detail">
	                <div class="input-title1">户型</div>
	                 <select name="door_model" class="door_model">
	                	<option value="1室1厅"> 1室1厅</option>
	                	<option value="2室1厅"> 2室1厅</option>
	                	<option value="2室2厅"> 2室2厅</option>
	                	<option value="3室1厅"> 3室1厅</option>
	                	<option value="3室2厅"> 3室2厅</option>
	                	<option value="4室1厅"> 4室1厅</option>
	                	<option value="4室2厅"> 4室2厅</option>
	                	<option value="5室2厅"> 5室2厅</option>
	                	
	              </select>
	                <p class="tips"></p>
	            </div>
	            <div id="door-detail">
	                <div class="input-title1">租房楼层</div>
	                <input type="text" name="renting_floor" class="door_model" placeholder="18">
	                <p class="tips"></p>
	            </div>
	            <div class="middle-input-block">
	            	<div class="input-title1"  style="float: left;">房屋图片</div>
				  <div class="layui-upload" style="float: left;">
					  <button type="button" class="layui-btn" id="upimg">上传图片</button>
					  <div class="layui-upload-list">
						<img class="layui-upload-img" style="width:200px;" id="imgpreview"> <!--这里的id里面的值要和后面js中的一致，不然无法回显-->
						<input type="hidden" name="img" id="img" class="middle-input"  >
					  </div>
					</div>  
				</div>
				
	        </div>
	    </div>

	   <div class="form-wrapper form-basic">
	            <div class="input-title" align="center">租金报价<span class="required">*</span></div>
					<input type="text" name="renting_price" class="middle-input" placeholder="" id="name">
	
	            	<p class="tips"></p>
	            </div>
	            <div>
	                <div class="input-title">整套面积<span class="required">*</span></div>
	                <input type="text" name="renting_area" class="middle-input" placeholder="">
	                <p class="tips"></p>
	            </div>
				<div>
	                <div class="input-title">租房类型<span class="required">*</span></div>
	                 <select name="rent_type" class="rent_type">
	                	<option value="整租"> 整租</option>
	                	<option value="合租"> 合租</option>
	              </select>
	                <p class="tips"></p>
	            </div>
				<div>
	                <div class="input-title">房屋朝向<span class="required">*</span></div>
	                <input type="text" name="renting_orientation" class="middle-input" placeholder="南、北">
	                <p class="tips"></p>
	            </div>
				<div>
	                <div class="input-title">地铁<span class="required">*</span></div>
	                <input type="text" name="near_subway" class="middle-input" placeholder="地铁几号线附近">
	                <p class="tips"></p>
	            </div>
				<div>
	                <div class="input-title">房屋类型<span class="required">*</span></div>
	                <input type="text" name="house_type" class="middle-input" placeholder="公寓，酒店，居民住宅">
	                <p class="tips"></p>
	            </div>
				<div>
	                <div class="input-title">装修类型<span class="required">*</span></div>
	                <input type="text" name="renting_fitment" class="middle-input" placeholder="精装修，普通">
	                <p class="tips"></p>
	            </div>
				<div>
	                <div class="input-title">看房地址<span class="required">*</span></div>
	                <input type="text" name="renting_address" class="middle-input" placeholder="">
	                <p class="tips"></p>
	            </div>
				<div>
	                <div class="input-title">房屋信息<span class="">*</span></div>
					<input type="text" name="renting_detail" class="middle-input" placeholder="" >
	                <p class="tips"></p>
	            </div>

	        <div class="layui-form-item layui-row layui-col-xs12">
	            <div class="steps" id="next-todetail" class="layui-input-block">
					<button id="peng" class= 'fbSubmit layui-btn layui-btn-normal' > 提交</button>
	            </div>
	        </div>


	</div>
	<script type="text/javascript">
 $(function(){
		layui.use('upload', function(){
		  var $ = layui.jquery
		  ,upload = layui.upload;
		  //普通图片上传
		  var uploadInst = upload.render({
			elem: '#upimg'
			,url: '/uploadfile'
			,accept:'images'
			,field:'file'
			//,method:'post'   //20200301修改，使用下面的before预加载来取出传值，只能用post，get的方法是另外的代码，目前还没搞懂
			,done: function(res){
				console.log(res)
				var imgsrc=res.url;
				document.getElementById("img").value = imgsrc;
				$("#imgpreview").attr("src",imgsrc)
				
			}
			,error: function(){
			  //演示失败状态，并实现重传
			  var demoText = $('#demoText');
			  demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
			  demoText.find('.demo-reload').on('click', function(){
				uploadInst.upload();
			  });
			}
		  });
		});
})

	$('.fbSubmit').click(function () {

 
	    var user_id = $('input[name=user_id]').val();
		var user_name = $('input[name=user_name]').val();
		var lan_mobile = $('input[name=lan_mobile]').val();
		var email = $('input[name=email]').val();
		var renting_title = $('input[name=renting_title]').val();

		var city = $('input[name=city]').val();
		var renting_floor = $('input[name=renting_floor]').val();
		var renting_address = $('input[name=renting_address]').val();
		var rent_type = $('.rent_type').val();

		var renting_orientation = $('input[name=renting_orientation]').val();
		var near_subway = $('input[name=near_subway]').val();
		var house_type = $('input[name=house_type]').val();
		var renting_fitment = $('input[name=renting_fitment]').val();
		var renting_detail = $('input[name=renting_detail]').val();

		var region = $('.region').val();
		var door_model = $('.door_model').val();
		var renting_price = $('input[name=renting_price]').val();
		var renting_area = $('input[name=renting_area]').val();
		var img = $('input[name=img]').val();
		if (lan_mobile == '' || lan_mobile == 'None' || email == '' || email == 'None'){
		    alert('请先完善个人信息');
		    return false
		}else if (renting_title == '' || renting_title == null){
		    alert('请给发布的加个醒目的标题吧！');
		    return false
		}else if (region == '' || region == null){
		    alert('请填写地区');
		    return false
		}else if (door_model == '' || door_model == null){
		    alert('请填写户型');
		    return false
		}else if (renting_area == '' || renting_area == null){
		    alert('请填写房子面积');
		    return false
		}

		$.ajax({
			type: 'POST',
			url: '/release',
			data: {
				'img': img,
			    'user_id': user_id,
			    'user_name': user_name,
				'renting_title': renting_title,
				'region': region,
				'city': city,
				'renting_floor': renting_floor,
				'renting_address': renting_address,
				'rent_type': rent_type,
				'renting_orientation': renting_orientation,
				'near_subway': near_subway,
				'house_type': house_type,
				'renting_fitment': renting_fitment,
				'renting_detail': renting_detail,
				'door_model': door_model,
				'renting_price': renting_price,
				'renting_area': renting_area
			},
			dataType: 'json',
			success: function (data) {
				if(data.result == 'ok'){
				    alert('发布成功，请等待审核');
				    window.location.href = window.location.href;
				}
				else{
				    alert('发布失败');
				}
            },
			error: function () {
				alert('网络出错啦....');
            }
		});
    });

</script>
 </body>
</html>



